<div id="LAY_app_body" class="layui-body">
    <div class="layadmin-tabsbody-item layui-show">
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card">
                    <div class="layui-card-header">管理员管理</div>
                    <div class="layui-card-body">
                        <form class="layui-form" action="/manage/Admin/addAdmin" lay-filter="addadmin_form" >
                            <div class="layui-col-md3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">角色分组</label>
                                    <div class="layui-input-block">
                                        <select class="layui-select" id="groupid" name="groupid" lay-search>
                                            <?php foreach($roleData as $k=>$v){?>
                                            <option value="<?php echo $v['id']?>" <?php if(!empty($admin['group_id']) && $admin['group_id']==$v['id']) echo 'selected';?> ><?php echo $v['title']?></option>
                                            <?php }?>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">登陆账号</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="username" name="username" placeholder="请输入管理员登陆账号"autocomplete="off"class="layui-input" lay-verify="required">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">管理员昵称</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="nickname" name="nickname" placeholder="请输入管理员昵称"
                                               autocomplete="off"
                                               class="layui-input" >
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">管理员密码</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="password" name="password" placeholder="请输入密码名称"
                                               autocomplete="off"
                                               class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <input type="hidden" id="id" name="id" >
                            <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit="" lay-filter="addadmin_submit">
                                            立即提交
                                        </button>
                                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                    </div>
                                </div>

                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form'], function () {
        var $ = layui.jquery,form = layui.form;
        var info = {:json_encode($admin)};
        form.val('addadmin_form',info);
        form.on("submit(addadmin_submit)",function(data){
            $.post("/manage/Admin/addAdmin",
                data.field
            ,function(res){
                if(res.code == 0){
                    $("#rolename").val("");
                    layer.alert(res.message,function(){
                        layer.closeAll();
                        location.href = res.url;
                    })
                }else{
                    layer.msg(res.message)
                }
            });
             return false;
        })
    });

</script>
